FROM centos:centos8.3.2011 AS builder

LABEL author=zhangjian

WORKDIR /build

# 编译nginx的依赖的
RUN yum -y install epel-release && yum -y install wget gcc gcc-c++ autoconf automake make pcre-devel openssl-devel zlib-devel
# 解压nginx源码
ADD nginx-1.18.0.tar.gz .
# 添加上传文件模板
COPY nginx-upload-module ./nginx-upload-module

# 运行编译命令
RUN cd /build/nginx-1.18.0 && ./configure --prefix=/janbar/nginx --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' --add-module='/build/nginx-upload-module' && make && make install

# 执行运行环境
FROM centos:centos8.3.2011

ENV TZ Asia/Shanghai

WORKDIR /janbar/nginx
COPY --from=builder /janbar/nginx /janbar/nginx

EXPOSE 80/tcp 443/tcp

# CMD ["nginx"]
